package com.help10000.rms.ui.adapter

import android.content.Context
import android.widget.ImageView
import com.amir.common.api.ApiContents
import com.amir.common.beans.Prod
import com.amir.common.holder.CommonViewHolder
import com.amir.common.mvp.base.BaseSingleItemTypeRecyclerViewAdapter
import com.amir.common.utils.ImageHelper
import com.help10000.rms.R

class SelectProductAdapter(mContext: Context, data: MutableList<Prod>, resId: Int) :
    BaseSingleItemTypeRecyclerViewAdapter<Prod>(mContext, data, resId) {

    override fun bindData(holder: CommonViewHolder, data: Prod, position: Int) {
        holder.setText(R.id.tv_name, data.ItemName)
        holder.setText(R.id.tv_style, data.ItemStyle)
        holder.setText(R.id.tv_price, "¥${data.Price}/${data.Unit}")
        holder.setText(R.id.tv_StockQty, "${data.StockQty}库存")
        holder.setOnClickListener(R.id.ll_root) {
            if (mOnItemClickListener != null) {
                mOnItemClickListener.onItem(position)
            }
        }
        var url = "${ApiContents.ImageUrl}${data?.Image}"
        var imgThumb = holder.getView<ImageView>(R.id.iv_image);
        ImageHelper.displayImage(mContext, url, imgThumb)
    }
}